package cn.doitedu.visualiz.platform.dao;

import org.jcodings.util.Hash;
import org.springframework.stereotype.Repository;

import java.sql.*;
import java.util.HashMap;
import java.util.Properties;

@Repository
public class FunnelAnalysisDaoImpl implements FunnelAnalysisDao {

    Connection connection;
    public FunnelAnalysisDaoImpl() throws SQLException {
        // URL parameters
        String url = "jdbc:presto://doitedu01:8080/hive/dwd18";
        Properties properties = new Properties();
        properties.put("user","admin");
        connection = DriverManager.getConnection(url, properties);

        System.out.println("preto 连接成....");
    }


    @Override
    public HashMap<String, String> queryUserCompleteStep(String sql) throws SQLException {

        System.out.println(sql);

        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery(sql);

        HashMap<String, String> mp = new HashMap<>();

        while(rs.next()){
            String guid = rs.getString(1);
            long step = rs.getLong(2);
            mp.put(guid,step+"");
        }

        return mp;
    }
}
